/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hanuma;

import java.util.*;
import com.google.gson.*;

/**
 *
 * @author niyaz
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
      /*  VKontakteApi vk = new VKontakteApi(Conf.token,Conf.id);
        try {
        vk.getFriends(Conf.id);
        vk.getCity(Conf.id);
        vk.getGraduation(Conf.id);
        System.out.println(vk.getSex("5374032"));
        } catch (Exception e){
        e.printStackTrace();
        }*/
        /* Persistent a= new PersistentInBase("mall");
        if (a.contains("us1")) {
        System.out.println("contains before");
        }
        a.put("us1");
        if (a.contains("us1")) {
        System.out.println("contains after");
        }*/

        /*VKontakteApi vk = new VKontakteApi(Conf.token, Conf.id);
        List<String> groups = null;
        try {
        groups = vk.getGroups(Conf.id);
        } catch (Exception e) {
        e.printStackTrace();
        }
        for (String str : groups) {
        System.out.println(str);
        }*/
        /*  VKontakteApi vk = new VKontakteApi(Conf.token, Conf.id);
        List<WallRecord> wall = null;
        try {
        wall = vk.getWall(Conf.id);
        } catch (Exception e){
        e.printStackTrace();
        }

        for (WallRecord r : wall){
        System.out.println(r.copy+" "+r.text);
        }
         */
        /*try {
        VKontakteApi vk = new VKontakteApi(Conf.token, Conf.id);
        Person p = vk.getPerson(Conf.id);
        Gson gson = new Gson();
        String json = gson.toJson(p);
        System.out.println(json);
        Person pers2 = gson.fromJson(json, Person.class);
        System.out.println(pers2.groups.get(0));
        } catch (Exception e) {
        e.printStackTrace();
        }
         */
        /*VKontakteApi vk = new VKontakteApi(Conf.token, Conf.id);
        List<String> albums = null;
        try {
        albums = vk.getNotes(Conf.id);
        } catch (Exception e) {
        e.printStackTrace();
        }
        for (String str : albums) {
        System.out.println(str);
        }*/
        
        filterUsers();

    }

    private static void findUsers() {
        Filling.run();
    }

    private static void localizeData() {
        try {
            VKontakteApi vk = new VKontakteApi(Conf.token, Conf.id);
            FileStoredPersonWriter store = new FileStoredPersonWriter("/home/niyaz/250/temp_store2");
            Persistent right = new PersistentInBase("mright");
            UserList userlist = right.getUserList();
            int i = 0;
            for (String user : userlist.list) {
                store.add(vk.getPerson(user));
                System.out.println(i++);
            }
            store.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void filterUsers() {
        List<Filter> filters = new ArrayList<Filter>(); // создаю список фильтров -
        //filters.add(new UniversalFilter(new BagOfWords("/home/niyaz/filters/house")));
        // filters.add(new UniversalFilter(new BagOfWords("/home/niyaz/filters/revolution")));
        filters.add(new UniversalFilter(new BagOfWords("../filters/himym")));

        try {
            ParameterizedUserList puserlist = new ParameterizedUserList("/home/niyaz/temp_store", filters);
            List<Double> factors = new ArrayList<Double>();
            factors.add(1.0);
            //  factors.add(1.0);
            //  factors.add(1.0);
            List<ParameterizedUser> users = puserlist.getBestN(100, factors);
            System.out.println("-------------------------------------");
            for (ParameterizedUser user : users) {
                System.out.println(user.user + " " + user.score);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
